
package jpoco.client;

import java.util.*;

@SuppressWarnings("serial")
public class Contact implements java.io.Serializable
{
	public static final String MALE = "male";
	public static final String FEMALE = "female";
	
	private String id;
	private String displayName;
	private String nickname;
	private String profileUrl;
	private Calendar published;
	private Calendar updated;
	private Calendar anniversary;
	private Name name;
	private String note;
	private String preferredUsername;
	private String utcOffset;
	private boolean connected = false;
	private String aboutMe;
	private String bodyType;
	private Location currentLocation;
	private String ethnicity;
	private String fashion;
	private String happiestWhen;
	private String humor;
	private String livingArrangement;
	private String lookingFor;
	private String profileSong;
	private String profileVideo;
	private String relationshipStatus;
	private String religion;
	private String romance;
	private String scaredOf;
	private String sexualOrientation;
	private String smoker;
	private String status;
	private java.util.Calendar birthday;
	private String gender;
	private String drinker;
	private List<String> tags;
	private List<Url> urls;
	private List<Email> emails;
	private List<PhoneNumber> phoneNumbers;
	private List<Photo> photos;
	private List<InstantMessagingAddress> instantMessagingAddresses;
	private List<Address> addresses;
	private List<Organization> organizations;
	private List<Account> accounts;

//	@SerializedName("relationships")
	private List<Relationship> relationships;
	
	private String children;  // OpenSocial only
	private String thumbnailUrl;  // OpenSocial only
	private List<String> books; // OpenSocial only
	private List<String> cars; // OpenSocial only
	private List<String> foods; // OpenSocial only
	private List<String> heroes; // OpenSocial only
	private List<String> interests; // OpenSocial only
	private List<String> languagesSpoken; // OpenSocial only
	private List<String> movies; // OpenSocial only
	private List<String> music; // OpenSocial only
	private List<String> pets; // OpenSocial only
	private List<String> quotes; // OpenSocial only
	private List<String> sports; // OpenSocial only
	private List<String> turnOffs; // OpenSocial only
	private List<String> turnOns; // OpenSocial only
	private List<String> tvShows; // OpenSocial only
	private List<String> politicalViews; // OpenSocial only
	private List<Activity> activities; // OpenSocial only
	private Integer age;  // OpenSocial only
	private NetworkPresence networkPresence; // OpenSocial only
	private Boolean isOwner = false;  // OpenSocial only
	private Boolean isViewer = false;  // OpenSocial only
	
	
	public Contact()
	{
		super();
		tags = new ArrayList<String>();
		urls  = new ArrayList<Url>();
		emails  = new ArrayList<Email>();
		phoneNumbers  = new ArrayList<PhoneNumber>();
		photos  = new ArrayList<Photo>();
		instantMessagingAddresses  = new ArrayList<InstantMessagingAddress>();
		addresses  = new ArrayList<Address>();
		organizations  = new ArrayList<Organization>();
		accounts  = new ArrayList<Account>();
		relationships = new ArrayList<Relationship>();
	}
	
	public String getId()
	{
		return id;
	}



	public void setId(String value)
	{
		this.id = value;
	}



	public String getDisplayName()
	{
		return displayName;
	}



	public void setDisplayName(String display)
	{
		this.displayName = display;
	}



	public Name getName()
	{
		return name;
	}



	public void setName(Name n)
	{
		this.name = n;
	}



	public java.util.Calendar getBirthday()
	{
		return birthday;
	}



	public void setBirthday(java.util.Calendar bday)
	{
		this.birthday = bday;
	}



	public String getGender()
	{
		return gender;
	}



	public void setGender(String g)
	{
		this.gender = g;
	}



	public String getDrinker()
	{
		return drinker;
	}



	public void setDrinker(String d)
	{
		this.drinker = d;
	}



	public List<String> getTags()
	{
		if (tags == null)
		{
			tags = new ArrayList<String>();
		}
		
		return tags;
	}

	public void addTag(String t)
	{
		this.tags.add(t);
	}



	public List<Url> getUrls()
	{
		if (urls == null)
		{
			urls = new ArrayList<Url>();
		}
		
		return urls;
	}



	public void addUrl(Url u)
	{
		this.urls.add(u);
	}


	public List<Email> getEmails()
	{
		if (emails == null)
		{
			emails = new ArrayList<Email>();
		}
		return emails;
	}



	public void addEmail(Email e)
	{
		this.getEmails().add(e);
	}



	public List<PhoneNumber> getPhoneNumbers()
	{
		if (phoneNumbers == null)
		{
			phoneNumbers = new ArrayList<PhoneNumber>();
		}
		
		return phoneNumbers;
	}




	public List<Photo> getPhotos()
	{
		if (photos == null)
		{
			photos = new ArrayList<Photo>();
		}
		
		return photos;
	}



	public void addPhoto(Photo p)
	{
		this.photos.add(p);
	}

	public List<InstantMessagingAddress> getInstantMessagingAddresses()
	{
		if (instantMessagingAddresses == null)
		{
			instantMessagingAddresses = new ArrayList<InstantMessagingAddress>();
		}
		
		return instantMessagingAddresses;
	}



	public void addInstantMessagingAddress(InstantMessagingAddress a)
	{
		this.instantMessagingAddresses.add(a);
	}

	public List<Address> getAddresses()
	{
		if (addresses == null)
		{
			addresses = new ArrayList<Address>();
		}
		return addresses;
	}

	public void addAddress(Address a)
	{
		this.getAddresses().add(a);
	}

	public List<Organization> getOrganizations()
	{
		if (organizations == null)
		{
			organizations = new ArrayList<Organization>();
		}
		
		return organizations;
	}



	public void addOrganization(Organization org)
	{
		this.organizations.add(org);
	}

	public List<Account> getAccounts()
	{
		if (accounts == null)
		{
			accounts = new ArrayList<Account>();
		}
		return accounts;
	}

	public void addAccount(Account a)
	{
		this.accounts.add(a);
	}

	public String getNickname()
	{
		return nickname;
	}

	public void setNickname(String n)
	{
		this.nickname = n;
	}

	public Calendar getPublished()
	{
		return published;
	}

	public void setPublished(Calendar pub)
	{
		this.published = pub;
	}

	public Calendar getUpdated()
	{
		return updated;
	}

	public void setUpdated(Calendar u)
	{
		this.updated = u;
	}

	public Calendar getAnniversary()
	{
		return anniversary;
	}

	public void setAnniversary(Calendar a)
	{
		this.anniversary = a;
	}

	public String getNote()
	{
		return note;
	}

	public void setNote(String n)
	{
		this.note = n;
	}

	public String getPreferredUsername()
	{
		return preferredUsername;
	}

	public void setPreferredUsername(String s)
	{
		this.preferredUsername = s;
	}

	public String getUtcOffset()
	{
		return utcOffset;
	}

	public void setUtcOffset(String offset)
	{
		this.utcOffset = offset;
	}

	public boolean isConnected()
	{
		return connected;
	}

	public void setConnected(boolean c)
	{
		this.connected = c;
	}

	public String getAboutMe()
	{
		return aboutMe;
	}

	public void setAboutMe(String about)
	{
		this.aboutMe = about;
	}

	public String getBodyType()
	{
		return bodyType;
	}

	public void setBodyType(String body)
	{
		this.bodyType = body;
	}

	public Location getCurrentLocation()
	{
		return currentLocation;
	}

	public void setCurrentLocation(Location loc)
	{
		this.currentLocation = loc;
	}

	public String getEthnicity()
	{
		return ethnicity;
	}

	public void setEthnicity(String e)
	{
		this.ethnicity = e;
	}

	public String getFashion()
	{
		return fashion;
	}

	public void setFashion(String f)
	{
		this.fashion = f;
	}

	public String getHappiestWhen()
	{
		return happiestWhen;
	}

	public void setHappiestWhen(String h)
	{
		this.happiestWhen = h;
	}

	public String getHumor()
	{
		return humor;
	}

	public void setHumor(String h)
	{
		this.humor = h;
	}

	public String getLivingArrangement()
	{
		return livingArrangement;
	}

	public void setLivingArrangement(String living)
	{
		this.livingArrangement = living;
	}

	public String getLookingFor()
	{
		return lookingFor;
	}

	public void setLookingFor(String looking)
	{
		this.lookingFor = looking;
	}

	public String getProfileSong()
	{
		return profileSong;
	}

	public void setProfileSong(String song)
	{
		this.profileSong = song;
	}

	public String getProfileVideo()
	{
		return profileVideo;
	}

	public void setProfileVideo(String video)
	{
		this.profileVideo = video;
	}

	public String getRelationshipStatus()
	{
		return relationshipStatus;
	}

	public void setRelationshipStatus(String s)
	{
		this.relationshipStatus = s;
	}

	public String getReligion()
	{
		return religion;
	}

	public void setReligion(String r)
	{
		this.religion = r;
	}

	public String getRomance()
	{
		return romance;
	}

	public void setRomance(String r)
	{
		this.romance = r;
	}

	public String getScaredOf()
	{
		return scaredOf;
	}

	public void setScaredOf(String s)
	{
		this.scaredOf = s;
	}

	public String getSexualOrientation()
	{
		return sexualOrientation;
	}

	public void setSexualOrientation(String orientation)
	{
		this.sexualOrientation = orientation;
	}

	public String getSmoker()
	{
		return smoker;
	}

	public void setSmoker(String s)
	{
		this.smoker = s;
	}

	public String getStatus()
	{
		return status;
	}

	public void setStatus(String s)
	{
		this.status = s;
	}

	public boolean isMale()
	{
		return MALE.equalsIgnoreCase(this.getGender());
	}
	
	public boolean isFemale()
	{
		return FEMALE.equalsIgnoreCase(this.getGender());
	}
	
	public void addPhoneNumber(PhoneNumber number)
	{
		this.phoneNumbers.add(number);
	}
	
	
	public List<Relationship> getRelationships()
	{
		if (relationships == null)
			
		{
			relationships = new ArrayList<Relationship>();
		}
		
		return relationships;
	}

	public void addRelationship(Relationship r)
	{
		this.relationships.add(r);
	}

	public String toString()
	{
		
		StringBuffer text = new StringBuffer();
		
		String name = null;
		
		if (this.getDisplayName() != null)
		{
			name = this.getDisplayName();
		}
		else if (this.getName() == null)
		{
			name = "unknown";
		}
		else if (this.getName().getFormatted() != null)
		{
			name = this.getName().getFormatted();
		}
		else
		{
			name = String.valueOf(this.getName().getGivenName()) + " " + String.valueOf(this.getName().getFamilyName());
		}
		
		text.append(name);
		text.append("\n");
		
		if (this.getNickname() != null)
		{
			text.append("nickname: " + getNickname());
		}
		
		for (Relationship r : this.getRelationships())
		{
			text.append("relationship: " + r.getValue());
			text.append("\n");
		}
		
		for (Email email : this.getEmails())
		{
			text.append(email.getValue());
			if (email.isPrimary())
			{
				text.append(" (primary)");
			}
			text.append("\n");
		}
		
		for (InstantMessagingAddress im : this.getInstantMessagingAddresses())
		{
			text.append(im.getType());
			text.append(":  ");
			text.append(im.getValue());
			if (im.isPrimary())
			{
				text.append(" (primary)");
			}
			text.append("\n");
		}
		
		for (Organization org : this.getOrganizations())
		{
			text.append(org.getName());
			if (org.isPrimary())
			{
				text.append(" (primary)");
			}
			text.append("\n");
			text.append(org.getTitle());
			text.append("\n");
		}
		
		for (Address a : this.getAddresses())
		{
			text.append(a.getFormatted());
			if (a.isPrimary())
			{
				text.append(" (primary)");
			}
			text.append("\n");
		}
		
		if (this.getStatus() != null)
		{
			text.append("status: " + getStatus());
		}
		
		if (this.getCurrentLocation() != null)
		{
			text.append("current location: " + getCurrentLocation());
		}
		
		if (this.getGender() != null)
		{
			text.append("gender: " + getGender());
		}
		
		if ( text.charAt(text.length() - 1) == '\n' )
		{
			text.deleteCharAt(text.length() - 1);
		}
		
		return text.toString();
	}

	public List<Account> getAccountsForDomain(String domain)
	{
		List<Account> result = new ArrayList<Account>();
		
		for (Account a : this.accounts)
		{
			if (domain.equals(a.getDomain()))
			{
				result.add(a);
			}
		}
		
		return result;
	}

	public List<String> getBooks()
	{
		if (books == null)
		{
			books= new ArrayList<String>();
		}
		return books;
	}

	public void addBook(String book)
	{
		this.getBooks().add(book);
	}

	public String getChildren()
	{
		return children;
	}

	public void setChildren(String c)
	{
		this.children = c;
	}

	public String getThumbnailUrl()
	{
		return thumbnailUrl;
	}

	public void setThumbnailUrl(String url)
	{
		this.thumbnailUrl = url;
	}

	public List<String> getCars()
	{
		if (cars == null)
		{
			cars = new ArrayList<String>();
		}
		return cars;
	}

	public void addCar(String c)
	{
		this.getCars().add(c);
	}

	public List<String> getFoods()
	{
		if (foods == null)
		{
			foods = new ArrayList<String>();
		}
		return foods;
	}

	public void addFood(String food)
	{
		this.getFoods().add(food);
	}

	public List<String> getHeroes()
	{
		if (heroes == null)
		{
			heroes = new ArrayList<String>();
		}
		return heroes;
	}

	public void addHero(String hero)
	{
		this.getHeroes().add(hero);
	}

	public List<String> getInterests()
	{
		if (interests == null)
		{
			interests = new ArrayList<String>();
		}
		return interests;
	}

	public void addInterest(String interest)
	{
		this.getInterests().add(interest);
	}

	public List<String> getLanguagesSpoken()
	{
		if (this.languagesSpoken == null)
		{
			languagesSpoken = new ArrayList<String>();
		}
		return languagesSpoken;
	}

	public void addLanguageSpoken(String lang)
	{
		this.getLanguagesSpoken().add(lang);
	}

	public List<String> getMovies()
	{
		if (movies == null)
		{
			movies = new ArrayList<String>();
		}
		return movies;
	}

	public void addMovie(String m)
	{
		this.getMovies().add(m);
	}

	public List<String> getMusic()
	{
		if (music == null)
		{
			music = new ArrayList<String>();
		}
		return music;
	}

	public void addMusic(String m)
	{
		this.getMusic().add(m);
	}

	public List<String> getPets()
	{
		if (pets == null)
		{
			pets = new ArrayList<String>();
		}
		return pets;
	}

	public void addPet(String pet)
	{
		this.getPets().add(pet);
	}

	public List<String> getQuotes()
	{
		if (quotes == null)
		{
			quotes = new ArrayList<String>();
		}
		return quotes;
	}

	public void addQuote(String quote)
	{
		this.getQuotes().add(quote);
	}

	public List<String> getSports()
	{
		if (sports == null)
		{
			sports = new ArrayList<String>();
		}
		return sports;
	}

	public void addSport(String sport)
	{
		this.getSports().add(sport);
	}

	public List<String> getTurnOffs()
	{
		if (turnOffs == null)
		{
			turnOffs = new ArrayList<String>();
		}
		return turnOffs;
	}

	public void addTurnOff(String turnOff)
	{
		this.getTurnOffs().add(turnOff);
	}

	public List<String> getTurnOns()
	{
		if (turnOns == null)
		{
			turnOns = new ArrayList<String>();
		}
		return turnOns;
	}

	public void addTurnOn(String turnOn)
	{
		this.getTurnOns().add(turnOn);
	}

	public List<String> getTvShows()
	{
		if (tvShows == null)
		{
			tvShows = new ArrayList<String>();
		}
		return tvShows;
	}

	public void addTvShow(String tvShow)
	{
		this.getTvShows().add(tvShow);
	}

	public List<String> getPoliticalViews()
	{
		if (politicalViews == null)
		{
			politicalViews = new ArrayList<String>();
		}
		return politicalViews;
	}

	public void addPoliticalView(String pview)
	{
		this.getPoliticalViews().add(pview);
	}
	
	public List<Activity> getActivities()
	{
		if (activities == null)
		{
			activities = new ArrayList<Activity>();
		}
		return activities;
	}
	
	public void addActivity(Activity a)
	{
		this.getActivities().add(a);
	}
	
	
	
	public Integer getAge()
	{
		return this.age;
	}
	
	public void setAge(Integer a)
	{
		this.age = a;
	}

	public String getProfileUrl()
	{
		return profileUrl;
	}

	public void setProfileUrl(String url)
	{
		this.profileUrl = url;
	}

	public NetworkPresence getNetworkPresence()
	{
		return networkPresence;
	}

	public void setNetworkPresence(NetworkPresence np)
	{
		this.networkPresence = np;
	}

	public Boolean isOwner()
	{
		return isOwner;
	}

	public void setOwner(Boolean b)
	{
		this.isOwner = b;
	}

	public Boolean isViewer()
	{
		return isViewer;
	}

	public void setViewer(Boolean b)
	{
		this.isViewer = b;
	}
	
	
}
